using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;
using System.IO.Pipes;
using Marin.Entities;

namespace Marin.Repository.Mapping
{
    public class CuentaMap : EntityTypeConfiguration<Cuenta>
    {
        public CuentaMap()
        {
            // Primary Key
            this.HasKey(t => t.Id);
            this.Property(p => p.Id)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);

            // Properties
            this.Property(t => t.Descripcion)
                .HasMaxLength(200);

            // Table & Column Mappings
            this.ToTable("Cuenta");
            this.Property(t => t.Id).HasColumnName("Id");
            this.Property(t => t.Descripcion).HasColumnName("Descripcion");           
            
            this.Property(t => t.Precio).HasColumnName("Precio");

            // Relationships
            this.HasRequired(p=>p.Categoria)
                .WithMany(pp=>pp.Cuentas)
                .HasForeignKey(p=>p.IdCategoria)
                .WillCascadeOnDelete(false);

        }
    }
}
